<?php
/* ========== ########## ========== ########## ========== ########## ========== */
/*                                                                              */
/*   WHMCS v4.1.2 NULLED R4 by FLIPMODE  [ BAD SYNTAX ]                         */
/*                                                                              */
/*                             INTERNAL BAD SYNTAX NULLED VERSION: 2.5.9.6 R4   */
/*                                                                              */
/*   ALL files have been analysed, cleaned and nulled of:                       */
/*     - Call Backs  (100%)                                                     */
/*     - Link Backs (95%)                                                       */
/*     - Licensing  (100%)                                                      */
/*     - Remote Links + URL's                                                   */
/*                                                                              */
/*   WHMCS v4.1.2 RELEASED: 4th November 2009                                   */
/*    -> FIRST v4.1.2 NULL R1: 19th November 2009                               */
/*    -> UPDATED v4.1.2 NULL R4: 27th November 2009                             */
/*                                                                              */
/*   TESTING + VERIFICATION::                                                   */
/*     Files Cleaned, Nulled, Checked, Verified By:                             */
/*      -> FLIPMODE!                                                            */
/*     Decoded By:                                                              */
/*      -> FLIPMODE! + Unknown Decoder                                          */
/*     Tested By:                                                               */
/*      -> FLIPMODE!, LeetWolf, and 12 Anonymous Users...                       */
/*     WHMCS 4.1.2 Supplied By:                                                 */
/*      -> WHM CompleteShit Coder @ WHMCS.com                                   */
/*                                                                              */
/*                                                                              */
/*   IMPORTANT NOTE::                                                           */
/*   PLEASE NOTE THIS IS FOR TRIAL PURPOSES ONLY!                               */
/*                          LIKE IT? THEN BUY IT!                               */
/*                                                                              */
/* ========== ########## ========== ########## ========== ########## ========== */

class licensing {
    public $licensekey = null;
    public $localkey = null;
    public $keydata = array ();
    public $secretkey = 'eJ2d73NC0hd515uaj2w8Vi1sj89f2nS64ydh9w5';
    public $incronrun = false;
    public $regname = 'Flipmode!';
    /*
    var $licensekey = null;
	var $localkey = null;
	var $keydata = array ();
	var $secretkey = 'eJ2d73NC0hd515uaj2w8Vi1sj89f2nS64ydh9w5';
	var $incronrun = false;
	function licensing () {
		global $license;
		global $CONFIG;
		$this->licensekey = $license;
		$this->localkey = $CONFIG['License'];
		$this->decodeLocal ();
    */

	/*
         if ($_GET['licensedebug'])
		{
			echo '<textarea cols=100 rows=10>License Key: ' . $this->licensekey . '
Version: ' . $CONFIG['Version'] . '
System URL: ' . $CONFIG['SystemURL'] . '
System SSL URL: ' . $CONFIG['SystemSSLURL'] . '
';
			print_r ($this->keydata);
			echo '</textarea><br>';
		}
    */

	/*
         if ($_GET['forceremote'])
		{
		   	$this->forceRemoteCheck ();
		}
    */

	/*
         if ($_GET['revokelocal'])
		{
			$this->revokeLocal ();
		}
    */

    public function licensing () {
         $this->licensekey = '1234567890';
         $this->localkey = $this->licensekey;

         $this->keydata = array (
              'status' => 'Active',
              'registeredname' => $regname . 'F L I P M O D E !',
              'productid' => 5,
              'latestversion' => $CONFIG['Version'],
              'productname' => 'Owned License No Branding',
              'regdate' => date ('Y-m-d'),
              'nextduedate' => '0000-00-00',
              'validdomain' => $_SERVER["HTTP_HOST"] . ",www." . $_SERVER["HTTP_HOST"],
              'validdirectory' => dirname (dirname (__FILE__)),
              'configoptions' => array (),
              'addons' => 'name=Support and Updates;nextduedate=2050-12-01;name=Configurable Package Addon;status=Active;'
         );
              /* 'addons' => 'name=Support and Updates;nextduedate=2050-12-01;name=Configurable Package Addon;status=Active;name=Branding Removal;status=Active;',

                $CONFIG['CompanyName'], */
}



	public function remotecheck ()	{
	/*
        $licensekey = $this->licensekey;
		$localkey = $this->localkey;
		$localkeydays = 10;
		$licensing_secret_key = $this->secretkey;
		$whmcsurl = 'http://74.54.136.210/~whmcscom/members/';
		$checkdate = date ('Ymd');
		$usersip = (isset ($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : $_SERVER['LOCAL_ADDR']);
		$allowcheckfaildays = 5;
		$localkeyvalid = false;
		if ($localkey) {
			$localkeyvalid = $this->decodeLocal ();
			if ($_GET['licensedebug']) {
				echo '' . 'Local Key Validation: ' . $localkeyvalid . '<br>';
			}
		}

		if ($localkeyvalid)	{
			$originalcheckdate = $this->keydata['checkdate'];
			$localexpiry = date ('Ymd', mktime (0, 0, 0, date ('m'), date ('d') - $localkeydays, date ('Y')));
			if ($originalcheckdate < $localexpiry) {
				$localkeyvalid = false;
				$this->keydata = array ();
			}
		}

		if (!$localkeyvalid) {
			$postfields['licensekey'] = $licensekey;
			$postfields['domain'] = $_SERVER['SERVER_NAME'];
			$postfields['ip'] = $usersip;
			$postfields['dir'] = ROOTDIR;
			if ($_GET['licensedebug']) {
				echo 'Performing Remote Check: ' . implode ('<br>', $postfields) . '<br>';
			}

			$ch = curl_init ();
			curl_setopt ($ch, CURLOPT_URL, $whmcsurl . 'modules/servers/licensing/verify.php');
			curl_setopt ($ch, CURLOPT_POST, 1);
			curl_setopt ($ch, CURLOPT_POSTFIELDS, $postfields);
			curl_setopt ($ch, CURLOPT_TIMEOUT, 30);
			curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
			$data = curl_exec ($ch);
			if (($_GET['licensedebug'] AND curl_error ($ch)))
			{
				echo 'Curl Error: ' . curl_error ($ch) . ' - ' . curl_errno ($ch) . '<br>';
			}

			curl_close ($ch);
			if ($_GET['licensedebug'])
			{
				echo '' . 'Raw Remote Response: ' . $data . '<br>';
			}

			if (!$data)
			{
				$localexpiry = date ('Ymd', mktime (0, 0, 0, date ('m'), date ('d') - ($localkeydays + $allowcheckfaildays), date ('Y')));
				if ($localexpiry < $originalcheckdate)
				{
					$results = $localkeyresults;
				}
				else
				{
					$results['status'] = 'noconnection';
				}
			}
			else
			{
				preg_match_all ('/<(.*?)>([^<]+)<\\/\\1>/i', $data, $matches);
				$results = array ();
				foreach ($matches[1] as $k => $v)
				{
					$results[$v] = $matches[2][$k];
				}
			}

			if ($results['status'] == 'Active')
			{
				$results['checkdate'] = $checkdate;
				$data_encoded = serialize ($results);
				$data_encoded = base64_encode ($data_encoded);
				$data_encoded = md5 ($checkdate . $licensing_secret_key) . $data_encoded;
				$data_encoded = strrev ($data_encoded);
				$data_encoded = $data_encoded . md5 ($data_encoded . $licensing_secret_key);
				$data_encoded = wordwrap ($data_encoded, 80, '
', true);
			}

			update_query ('tblconfiguration', array ('value' => $data_encoded), array ('setting' => 'License'));
    */

            return true;
            $results['remotecheck'] = true;

	/*
            $this->keydata = $results;
    */

    	}

    /*
    		if ($_GET['licensedebug'])
		{
			exit ('Remote Check Completed');
		}

		unset ($postfields);
		unset ($data);
		unset ($matches);
		unset ($whmcsurl);
		unset ($licensing_secret_key);
		unset ($checkdate);
		unset ($usersip);
		unset ($localkeydays);
		unset ($allowcheckfaildays);
		unset ($md5hash);
	}
    */

	public function forceremotecheck ()
	{
    /*
    	$this->localkey = '';
		$this->remoteCheck ();
    */
        return true;
    }

	public function decodelocal ()
	{
    /*
    	$localkey = $this->localkey;
		$licensing_secret_key = $this->secretkey;
		$usersip = (isset ($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : $_SERVER['LOCAL_ADDR']);
		$localkey = str_replace ('
', '', $localkey);
		$localdata = substr ($localkey, 0, strlen ($localkey) - 32);
		$md5hash = substr ($localkey, strlen ($localkey) - 32);
		if ($md5hash == md5 ($localdata . $licensing_secret_key))
		{
			$localdata = strrev ($localdata);
			$md5hash = substr ($localdata, 0, 32);
			$localdata = substr ($localdata, 32);
			$localdata = base64_decode ($localdata);
			$localkeyresults = unserialize ($localdata);
			$originalcheckdate = $localkeyresults['checkdate'];
			if ($md5hash == md5 ($originalcheckdate . $licensing_secret_key))
			{
			*/

                $localkeyvalid = true;
                return true;

            /*	$results = $localkeyresults;
				$validdomains = explode (',', $results['validdomain']);
				if ($results['status'] != 'Active')
				{
					$localkeyvalid = false;
					if ($_GET['licensedebug'])
					{
						echo 'Local Key Validation Failed at Status Check<br>';
					}
				}

				if ((!$this->incronrun AND !in_array ($_SERVER['SERVER_NAME'], $validdomains)))
				{
					$localkeyvalid = false;
					$results = array ();
					$results['status'] = 'Invalid';
					if ($_GET['licensedebug'])
					{
						echo 'Local Key Validation Failed at Domain Check<br>';
					}
				}

				if ($results['validip'])
				{
					$validips = explode (',', $results['validip']);
				}

				if ((((!$this->incronrun AND $usersip) AND $validips) AND !in_array ($usersip, $validips)))
				{
					$localkeyvalid = false;
					$results = array ();
					$results['status'] = 'Invalid';
					if ($_GET['licensedebug'])
					{
						echo 'Local Key Validation Failed at IP Check<br>';
					}
				}

				if ($results['validdirectory'] != ROOTDIR)
				{
					$localkeyvalid = false;
					$results = array ();
					$results['status'] = 'Invalid';
					if ($_GET['licensedebug'])
					{
						echo 'Local Key Validation Failed at Directory Check<br>';
					}
				}
			}
			else
			{
				if ($_GET['licensedebug'])
				{
					echo 'Local Key MD5 Hash 2 Invalid<br>';
				}
			}
		}
		else
		{
			if ($_GET['licensedebug'])
			{
				echo 'Local Key MD5 Hash Invalid<br>';
			}
		}



		if ($localkeyvalid)
		{
			$configoptions = array ();
			$tempresults = explode ('|', $results['configoptions']);
			foreach ($tempresults as $tempresult)
			{
				$values = explode ('=', $tempresult);
				$configoptions[$values[0]] = $values[1];
			}

			$results['configoptions'] = $configoptions;
			$tempresults = explode ('|', html_entity_decode ($results['addons']));
			foreach ($tempresults as $tempresult)
			{
				$tempresults2 = explode (';', $tempresult);
				$temparr = array ();
				foreach ($tempresults2 as $tempresult)
				{
					$tempresults3 = explode ('=', $tempresult);
					$temparr[$tempresults3[0]] = $tempresults3[1];
				}

				$addons[] = $temparr;
			}

			$results['addons'] = $addons;
		}

		if ($results['nextduedate'] == '0000-00-00')
		{
    */

        	$results['nextduedate'] = 'Never';
            return true;
    /*
        }

		$this->keydata = $results;
		return $localkeyvalid;
	*/

    }




	public function revokelocal ()
	{

    /*
    	update_query ('tblconfiguration', array ('value' => ''), array ('setting' => 'License'));
    */

        return true;

    }



    public function getstatus ()
	{
		return true;
        return $this->keydata['status'];
    }



	public function getbrandingremoval ()
	{
		/* if (($this->keydata['productname'] == 'Owned License No Branding' OR $this->keydata['productname'] == 'Monthly Lease No Branding'))  */

		/* if ($this->keydata['productname'] == 'Owned License No Branding')
        {
			return true;
		}
        else
        {    */
            return true;
    /*    }
		if ($this->keydata['addons']) {
			foreach ($this->keydata['addons'] as $addon) {
				// if (($addon['name'] == 'Branding Removal' AND $addon['status'] == 'Active')) {
					return true;
					continue;
				}
			}
		}

		return false;
    */

	}
}

?>